//==========================================================================
// Copyright (c) 2000-2009,  Elastos, Inc.  All Rights Reserved.
//==========================================================================
#ifndef __CGRAFIXLAYER_H__
#define __CGRAFIXLAYER_H__

#include <engine.h>

#define _NO_CGRAFIXLAYER_CLASSOBJECT_
#include "_CGrafixLayer.h"

typedef struct {
        Rectangle screen;
        Int32 bitsPerPixel;
        PixelFormat pixelFormat;
        Int32 addressCount;
        Address systemAddress[3];
        UInt32 size[3];
        Int32 layer;
} DisplayInformation;

class CGrafixEngine;

CarClass(CGrafixLayer)
{
public:
    CGrafixLayer()
    {
        DebugBreak();
    }

    CGrafixLayer(
        /* [in] */ CGrafixEngine * pEngine,
        /* [in] */ Handle32 layer);

    ~CGrafixLayer();

    Void *operator new(size_t size, void * pv) { return pv; }

    Void *operator new(size_t size) { return malloc(size); }

    Void operator delete(void * pv) { free(pv); }

public:
    CARAPI Enable(
        /* [in] */ const struct GrafixLayerFormat & layerFormat);

    CARAPI Disable();

    CARAPI SetOpacity(
        /* [in] */ Int32 opacity);

    CARAPI GetAttributes(
        /* [out] */ struct GrafixLayerFormat * pLayerFormat,
        /* [out] */ Boolean * pEnabled);

public:
    ECode Render(
        /* [in] */ CGrafixSurface * pSurface);

    ECode Render();

    ECode RenderRegion(
        /* [in] */ Int32 x,
        /* [in] */ Int32 y,
        /* [in] */ Int32 width,
        /* [in] */ Int32 height);

    ECode RenderRegion(
        /* [in] */ Int32 x,
        /* [in] */ Int32 y,
        /* [in] */ Int32 width,
        /* [in] */ Int32 height,
        /* [in] */ CGrafixSurface * pSurface);

    Void Render2Framebuffer(
        /* [in] */ CGrafixSurface * pSurface,
        /* [in] */ Rectangle * pUpdateRectangle,
        /* [in] */ ScreenOrientation orientation);

    Void TranparentLayer(
        /* [in] */ Rectangle * pTransparentRectangle,
        /* [in] */ ScreenOrientation orientation);

public:
    Boolean m_enable;

    CGrafixEngine* m_engine;
    IDeviceDriver* m_vga;

    DisplayInformation m_info;
};

#endif // __CGRAFIXLAYER_H__
